package cm.dayo7;

import java.util.ArrayList;

public class Test3 {
    public static void main(String[] args) {
        ArrayList<Student>list=new ArrayList<>();
        list.add(new Student("张三",23,"男"));
        list.add(new Student("李四",24,"女"));
        list.add(new Student("王五",26,"男"));
        int max=list.get(0).getAge();
        int temp=0;
        for (int i = 0; i < list.size(); i++) {
            if (max<list.get(i).getAge()){
                max=list.get(i).getAge();
                temp=i;
            }
            if (temp== list.size()-1){
                list.get(i).setName("小猪佩奇");
            }

        }
        for (Student student : list) {
            System.out.println(student);
        }

    }
}
